<!--
 * @Author: zhangjingyu
 * @Date: 2021-04-01 10:57:57
 * @LastEditors: zhangjingyu
 * @LastEditTime: 2021-04-01 14:45:55
 * @FilePath: \vprisk10.14\src\views\ftpManage\pricingManage\sceneTask\positionTable.vue
 * @Description: 头寸表选择控件
-->
<template>
  <div>
    <el-dialog
      v-dialogDrag
      title="头寸表数据"
      :visible.sync="visible"
      width="514px"
      append-to-body
    >
      <upper-template
        @search="search()"
        @clear="searchForm.pdPostFix='',searchForm.pdName=''"
        :configIcon="false"
      >
        <!-- 操作按钮区 -->
        <template slot="buttonArea">
          <el-button @click="checkComfirm" >确定</el-button>
        </template>
        <!-- 搜索区 -->
        <template slot="searchArea">
          <el-form
            :model="searchForm"
            ref="searchForm"
            label-width="60px"
            label-position="left"
            size="mini"
          >
            <el-form-item label="后缀：">
              <el-input
                v-model="searchForm.pdPostFix"
                style="width:150px"
              ></el-input>
            </el-form-item>
             <el-form-item label="名称：">
              <el-input
                v-model="searchForm.pdName"
                style="width:150px"
              ></el-input>
            </el-form-item>
          </el-form>
        </template>
      </upper-template>
      
      <el-table ref="multipleTable" :data="tableData" @row-click="rowChecked">
      <el-table-column width="55" type="selection"></el-table-column>
      <el-table-column prop="pdPostFix" label="后缀" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="pdName" label="表名" show-overflow-tooltip>
      </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
import { pricingTask } from "@/api/index";
export default {
  data() {
    return {
      visible: false,
      tableData: [],
      searchForm: {
        pdPostFix: "",
        pdName: ""
      }
    };
  },
  props: {
    positionShow: {
      type: Boolean,
      default: false
    }
  },
  watch: {
    positionShow(n, o) {
      this.visible = n;
      this.search();
    },
    visible(n, o) {
      this.$emit("update:positionShow", n);
    }
  },
  created() {
    this.search();
  },
  methods: {
    search() {
        let data = this.searchForm;
      pricingTask.positionFindAllEnable(data).then(res => {
        if (res.code == 200) {
          this.tableData = res.datas;
        }
      });
    },
    checkComfirm() {
      let selection = this.$refs.multipleTable.selection;
      if (selection.length < 1) {
        return this.$message.warning("请至少选择一条数据");
      }
      this.$emit("check", selection);
    },
    rowChecked(row) {
      if (this.$refs.multipleTable) {
        this.$refs.multipleTable.clearSelection();
        this.$refs.multipleTable.toggleRowSelection(row, true);
      }
    }
  }
};
</script>

<style lang="scss" scoped>
</style>